# Version 0.0.1
FROM java
ARG PROJECT_NAME
MAINTAINER yangchao "yangchao.cool@gmail.com"

#RUN
RUN sed  -i 's/DEBUG/INFO/g' `find /app/pinpoint-agent -name log4j.xml`

ENV JAVA_OPTS="\
-server \
-Xmx800m \
-Xms800m \
-Xss256k \
-XX:-UseGCOverheadLimit \
-XX:SurvivorRatio=8 \
-XX:MetaspaceSize=256m \
-XX:MaxMetaspaceSize=512m \
-XX:+UseParallelGC \
-XX:ParallelGCThreads=4 \
-XX:+UseParallelOldGC \
-XX:+UseAdaptiveSizePolicy \
-XX:+PrintGCDetails \
-XX:+PrintTenuringDistribution \
-XX:+PrintGCTimeStamps \
-XX:+HeapDumpOnOutOfMemoryError \
-XX:HeapDumpPath=/app/logs/jvm \
-Xloggc:/app/logs/jvm/gc.log \
-XX:+UseGCLogFileRotation \
-XX:NumberOfGCLogFiles=5 \
-XX:GCLogFileSize=10M "
run echo ${PROJECT_NAME}
ENV WORK_PATH /app
ENV APP_NAME ${PROJECT_NAME}
ENV APP_VERSION 1.0.0-SNAPSHOT.jar
ENV APP_FULL_NAME ${PROJECT_NAME}-1.0.0-SNAPSHOT.jar
ENV TZ=Asia/Shanghai
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
#EXPOSE 8080

#USER
#USER user:group

#VOLUME
VOLUME ["/app", "/tmp/app"]

#ADD

#COPY
COPY $APP_FULL_NAME $WORK_PATH/

#LABEL
#STOPSIGNAL
#ARG
#ONBUILD

# WORKDIR
WORKDIR $WORK_PATH
ENTRYPOINT java $JAVA_OPTS  -XX:OnOutOfMemoryError='kill -9 %p' -Djava.security.egd=file:/dev/./urandom -Dspring.profiles.active=dev -jar $APP_FULL_NAME
